package com.lwx.setAndMap;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;

public class Solution804 {
    public static void main(String[] args) {

    }
    public int uniqueMorseRepresentations(String[] words) {
        String[] passwordSheet ={".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."};

        Set<String> result = new TreeSet<>();
        for (String word: words) {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < word.length(); i++) {
                //char类型的相减，'a'作为偏移量
                sb.append(passwordSheet[word.charAt(i) - 'a']);
            }
            result.add(sb.toString());
        }

        return result.size();
    }
}
